#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Last Update:

'''docstring
'''

__revision__ = '0.1'
__author__ = 'lxd'
import os
import pickle

sina_consumer_key= "3914859330"
sina_consumer_secret ="5ce60946d31eb68a338dd52bcdc5b194"

douban_consumer_key = '0e8c11d786bd99d72ba435869438cd85'
douban_consumer_secret = 'b3861e96db11a789'

user_file = 'user.info'
init_data = {'chkSina':True, 'chkDouban':True, 'chkJavaeye':True, 'sina_token_key':'', 'sina_token_secret':'', 'douban_token_key':'', 'douban_token_secret':'', 'javaeye_name':'', 'javaeye_pwd':''}

def loadUserData():
    """读用户数据
    """
    if not os.path.isfile(user_file):
        data = init_data
    else:
        f = open(user_file, 'r')
        data = f.read()
        f.close()
        data = pickle.loads(data)
    return data

def saveUserData(**kwargs):
    """读用户数据, 然后更改元素, 然后写入
    """
    data = loadUserData()
    f = open(user_file, 'w')
    for key, value in kwargs.items():
        data.update({key:value})
    data = pickle.dumps(data)
    f.write(data)
    f.close()

if __name__ == '__main__':
    pass
